package Month11.Day8;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public class SetMethod {
    public static void main(String[] args) {
        Set<Student> set=new HashSet<>();
        Student s1 = new Student("小甲", 20);
        Student s2 = new Student("小乙", 18);
        /*
                     boolean add(Object o)
         */
        set.add(s1);
        set.add(s2);
        /*
                     void clear
         */
//          set.clear();
          /*
                     int size
           */
        System.out.println(set.size());
        /*
                      boolean isEmpty()
         */
        System.out.println(set.isEmpty());

        /*
                      boolean contains(Object o)

       */
        System.out.println(set.contains(s1));
        System.out.println(set.contains("小甲"));
        /*
                       boolean remove(Object o)
         */
        System.out.println(set.remove(s1));

        Iterator<Student> iterator = set.iterator();
        while (iterator.hasNext()){
            Student student= iterator.next();
            System.out.println(student);
        }
    }
}
